var e = require("3F2EFC058A52ABCF59489402DCA7FE64.js"), t = require("A1901C218A52ABCFC7F674269787FE64.js");

App({
    onLaunch: function(e) {
        var t = wx.getSystemInfoSync(), a = t.screenHeight, n = t.windowWidth, i = a * (750 / n);
        this.globalData.winHeight = i, this.globalData.winWidth = n, this.globalData.statusBarHeight = t.statusBarHeight, 
        this.globalData.headerBtnPosi = wx.getMenuButtonBoundingClientRect();
        var o = wx.getLaunchOptionsSync();
        this.globalData.scene = o.scene, console.log(e.query), e.query && e.query.key && (this.globalData.key = e.query.key, 
        this.handleOpenid(this.executeThridPartLogin));
    },
    handleOpenid: function(e) {
        wx.login({
            success: function(a) {
                var n = a.code;
                wx.request({
                    url: t.domain + "/v7/wechat/miniprogram/login",
                    data: {
                        app_id: t.WXAPPID,
                        app_key: t.WXAPPSCREPT,
                        js_code: n,
                        grant_type: "authorization_code"
                    },
                    dataType: "json",
                    success: function(t) {
                        var a = JSON.parse(t.data);
                        console.log("miniprogram = " + t.data), e && e(a.openid);
                    },
                    fail: function(e) {
                        console.log(e);
                    }
                });
            }
        });
    },
    executeThridPartLogin: function(a) {
        var n = this, i = (0, e.generateSignature)("/basic/mp/user-login"), o = i.nonce, s = i.timestamp, r = i.appKey, c = i.appId, g = i.signature;
        a ? wx.request({
            url: t.thirdPartyDomain + "/basic/mp/user-login",
            method: "POST",
            data: {
                appKey: r,
                timestamp: s,
                nonce: o,
                signature: g,
                appId: c,
                openid: a,
                key: n.globalData.key
            },
            success: function(e) {
                if (200 == e.statusCode) {
                    var t = e.data;
                    console.log("user-login = " + JSON.stringify(e.data)), t.code || (n.globalData.skey = t.skey);
                }
            }
        }) : console.log("请先获取openid");
    },
    openPageMore: function() {
        getCurrentPages().length >= 10 && wx.showToast({
            title: "页面打开太多，请回退关闭几个页面",
            icon: "none",
            duration: 2e3
        });
    },
    globalData: {
        winHeight: "",
        winWidth: "",
        statusBarHeight: "",
        headerBtnPosi: {},
        sence: "",
        skey: "",
        key: ""
    }
});